package com.cib.fintech.entrustedinvestment.quartz.task;

import com.cib.fintech.entrustedinvestment.biz.domain.TransferOrder;
import com.cib.fintech.entrustedinvestment.biz.repository.TransferOrderRepository;
import com.cib.fintech.entrustedinvestment.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class BookValueFileTask {
    public static final Logger logger = LoggerFactory.getLogger(BookValueFileTask.class);

    @Autowired
    private TransferOrderRepository transferOrderRepository;

    public void run(){
        List<String> tenIdList= transferOrderRepository.findDistinctTenId();
        for(String tenId : tenIdList){
            List<TransferOrder> transferOrderList = transferOrderRepository.findByTenId(tenId);
            List<String> financeProductIdList=new ArrayList<>();
            for (TransferOrder transferOrder:transferOrderList) {
                if(StringUtils.isNotEmpty(transferOrder.getFinanceProductId())&&!financeProductIdList.contains(transferOrder.getFinanceProductId())){
                    financeProductIdList.add(transferOrder.getFinanceProductId());
                }
            }

            System.out.println(transferOrderList);
        }

        System.out.println("aaaaaaaaaaaaaaaa");
    }
}
